<?php 

// $get=$_GET['id']? $_GET['id']:'';

require_once '../config.php';
require_once '../functions.php';



function make_add(){
  
    if(empty($_POST['email'])){
        $GLOBALS['message']="请填写邮箱";
    }
    
    if(empty($_POST['slug'])){
        $GLOBALS['message']="请填写名字";
    }
    if(empty($_POST['make_nick'])){
        $GLOBALS['message']="请填写昵称";
    }
    if(empty($_POST['make_data'])){
        $GLOBALS['message']="请填写日期";
    }
    if(empty($_POST['ISBN'])){
        $GLOBALS['message']="请填写日期";
    }
    if(empty($_POST['content'])){
        $GLOBALS['message']="请填写内容";
    }

    $email= $_POST['email'];
    $slug= $_POST['slug'];
    $nick=$_POST['make_nick'];
    $data=$_POST['make_data'];
    $ISBN=$_POST['ISBN'];
    $content = $_POST['content'];

    $rows =book_execute("insert into make values (null,'{$slug}','{$email}','{$nick}','{$content}','{$data}','{$ISBN}');");
    // insert into make values(null,'天天','175@qq.com','你好','撒旦法沙发撒旦法','2020-03-19 17:15:32',151);
    $GLOBALS['success'] = $rows > 0;
    $GLOBALS['message'] = $rows <= 0 ? '添加失败！' : '添加成功！';

   
};


if(empty($_GET['id'])){
    if($_SERVER['REQUEST_METHOD']==='POST'){
        make_add();
    }
} 



?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>Users &laquo; Admin</title>
  <link rel="stylesheet" href="/static/assets/vendors/bootstrap/css/bootstrap.css">
  <link rel="stylesheet" href="/static/assets/vendors/font-awesome/css/font-awesome.css">
  <link rel="stylesheet" href="/static/assets/vendors/nprogress/nprogress.css">
  <link rel="stylesheet" href="/static/assets/css/admin.css">
  <script src="/static/assets/vendors/nprogress/nprogress.js"></script>
</head>
<body>
  <script>NProgress.start()</script>

  <div class="main">
  <?php include 'inc/navbar_admin.php'; ?>

    <div class="container-fluid">
      <div class="page-title">
        <h1>用户</h1>
      </div>
      <?php if (isset($message)): ?>
     <?php if ($success):?>
              <!-- 有错误信息时展示 -->
      <div class="alert alert-success">
        <strong>成功！</strong><?php echo $message;?>
      </div>
    <?php else:?>
       <div class="alert alert-danger">
        <strong>错误！</strong><?php echo $message;?>
      </div>
     <?php endif ?>
     <?php endif ?>
      <div class="row">
        <div class="col-md-6">
            <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
            <h2>添加新用户</h2>
            <div class="form-group">
              <label for="email">邮箱</label>
              <input id="email" class="form-control" name="email" type="email" placeholder="邮箱">
            </div>
            <div class="form-group">
              <label for="slug">名字</label>
              <input id="slug" class="form-control" name="slug" type="text" placeholder="slug">
            </div>
            <div class="form-group">
              <label for="make_nick">昵称</label>
              <input id="make_nick" class="form-control" name="make_nick" type="text" placeholder="昵称">
            </div>
            <div class="form-group">
              <label for="make_data">日期</label>
              <input id="make_data" class="form-control" name="make_data" type="date" placeholder="日期">
            </div>
            <div class="form-group">
              <label for="ISBN">ISBN</label>
              <input id="ISBN" class="form-control" name="ISBN" type="text" placeholder="日期">
            </div>
            <div class="form-group">
              <label for="content">内容</label>
              <textarea class="form-control" name="content" id="content" cols="30" rows="10"></textarea>
            </div>
            <div class="form-group">
              <button class="btn btn-primary" type="submit">添加</button>
            </div>
          </form>
         
        </div>
       
      </div>
    </div>
  </div>
  
  <?php include 'inc/sidebar.php'; ?>
  <script src="/static/assets/vendors/jquery/jquery.js"></script>
  <script src="/static/assets/vendors/bootstrap/js/bootstrap.js"></script>
  <script>NProgress.done()</script>
</body>
</html>
